package com.prd.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.prd.api.RemoteUserService;
import com.prd.config.LoginInterceptor;
import com.prd.constant.MeetSignStatus;
import com.prd.constant.MeetStatus;
import com.prd.constant.UserStatus;
import com.prd.dto.EntMeetDto;
import com.prd.dto.MatterDto;
import com.prd.dto.SummaryVoteDto;
import com.prd.mapper.EntMeetMapper;
import com.prd.model.*;
import com.prd.service.*;
import com.prd.util.StringsUtils;
import com.prd.util.UserInfoUtil;
import com.prd.vo.EntMeetVo;
import com.prd.vo.MatterVo;
import com.prd.vo.MeetPresentVo;
import com.prd.vo.UserVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class EntMeetServiceImpl extends ServiceImpl<EntMeetMapper, EntMeet> implements EntMeetService {

    @Autowired
    private EntMeetMapper entMeetMapper;

    @Autowired
    private EntMeetSignService entMeetSignService;

    @Autowired
    private EntInviteService entInviteService;

    @Autowired
    private EntMeetRecordService entMeetRecordService;

    @Autowired
    private EntMeetSummaryService entMeetSummaryService;

    @Autowired
    private RemoteUserService remoteUserService;

    @Override
    public int insertEntMeet(EntMeet entMeet) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        entMeet.setStatus(1);
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), true), entMeet);
        return entMeetMapper.insert(entMeet);
    }

    @Override
    public int updateEntMeet(EntMeet entMeet) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), false), entMeet);
        return entMeetMapper.updateById(entMeet);
    }

    @Override
    public List<EntMeetVo> listInfo(EntMeetDto entMeetDto) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        LambdaQueryWrapper<EntMeet> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.between(entMeetDto.getMeetStartTime() != null && entMeetDto.getMeetEntTime() != null, EntMeet::getStartTime, entMeetDto.getMeetStartTime(), entMeetDto.getMeetEntTime());
        queryWrapper.eq(entMeetDto.getStatus() != null, EntMeet::getStatus, entMeetDto.getStatus());
//        queryWrapper.eq(EntMeet::getDelFlag, UserStatus.OK.getCode());
        List<EntMeet> list = entMeetMapper.selectList(queryWrapper);
        List<EntMeetVo> listEntMeetVo = new ArrayList<>();
        for (EntMeet entMeet : list) {
            EntMeetVo entMeetVo = new EntMeetVo();
            BeanUtils.copyProperties(entMeet, entMeetVo);

            List<Long> conveners = Arrays.asList(StringsUtils.convert(entMeet.getConvener().split(",")));
            List<Long> principals = Arrays.asList(StringsUtils.convert(entMeet.getPrincipal().split(",")));
            List<Long> supervisions = Arrays.asList(StringsUtils.convert(entMeet.getSupervision().split(",")));
            List<Long> comperes = Arrays.asList(StringsUtils.convert(entMeet.getCompere().split(",")));
            List<Long> notekeepers = Arrays.asList(StringsUtils.convert(entMeet.getNotekeeper().split(",")));
            List<Long> arrayList = new ArrayList<>();
            arrayList.addAll(conveners);
            arrayList.addAll(principals);
            arrayList.addAll(supervisions);
            arrayList.addAll(comperes);
            arrayList.addAll(notekeepers);

            List<Long> interiorPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getInteriorPersonnel().split(",")));
            List<Long> externalPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getExternalPersonnel().split(",")));
            arrayList.addAll(interiorPersonnels);
            arrayList.addAll(externalPersonnels);

            arrayList.stream().distinct().collect(Collectors.toList());

            //判断是否有查询权限
            if (arrayList.contains(loginUser.getId())) {
                List<UserVo> listUser = remoteUserService.listInfo(arrayList.toArray(new Long[arrayList.size()])).getData();

                List<String> list1 = new ArrayList<>();
                List<String> list2 = new ArrayList<>();
                List<String> list3 = new ArrayList<>();
                List<String> list4 = new ArrayList<>();
                List<String> list5 = new ArrayList<>();
                List<String> list6 = new ArrayList<>();
                List<String> list7 = new ArrayList<>();
                List<String> list8 = new ArrayList<>();
                List<String> list9 = new ArrayList<>();
                for (UserVo userVo : listUser) {
                    if (conveners.contains(userVo.getId())) {//会议召集人
                        list1.add(userVo.getName() + " " + userVo.getTelephone());
                    }
                    if (principals.contains(userVo.getId())) {//会议负责人
                        list2.add(userVo.getName() + " " + userVo.getTelephone());
                    }
                    if (supervisions.contains(userVo.getId())) {//会议督导人
                        list3.add(userVo.getName() + " " + userVo.getTelephone());
                    }
                    if (comperes.contains(userVo.getId())) {//会议主持人
                        list4.add(userVo.getName() + " " + userVo.getTelephone());
                    }
                    if (notekeepers.contains(userVo.getId())) {//会议记录人
                        list5.add(userVo.getName() + " " + userVo.getTelephone());
                    }
                    //参会人员
                    if (interiorPersonnels.contains(userVo.getId()) || externalPersonnels.contains(userVo.getId())) {
                        list6.add(userVo.getName());
                    }

                    //会议中后
                    if (entMeetVo.getStatus() == MeetStatus.TWO.getCode() || entMeetVo.getStatus() == MeetStatus.THREE.getCode()) {
                        LambdaQueryWrapper<EntMeetSign> meetSignLambdaQueryWrapper = new LambdaQueryWrapper<>();
                        meetSignLambdaQueryWrapper.eq(EntMeetSign::getMeetId, entMeetVo.getId());
                        meetSignLambdaQueryWrapper.in(EntMeetSign::getStatus, 1, 4);
                        List<EntMeetSign> listMeetSign = entMeetSignService.list(meetSignLambdaQueryWrapper);
                        listMeetSign.stream().forEach(item -> {
                            if (item.getStatus() == 1) {//签到
                                //实到人员
                                if (item.getCreateId() == userVo.getId()) {
                                    list7.add(userVo.getName());
                                }
                                //迟到人员
                                if (item.getCreateTime().compareTo(entMeetVo.getStartTime()) > 0) {
                                    list8.add(userVo.getName());
                                }
                            }
                            if (item.getStatus() == 4) {//请假
                                list9.add(userVo.getName());
                            }
                        });
                    }
                }

                entMeetVo.setConvener(list1);
                entMeetVo.setPrincipal(list2);
                entMeetVo.setSupervision(list3);
                entMeetVo.setCompere(list4);
                entMeetVo.setNotekeeper(list5);
                entMeetVo.setConferee(list6);
                entMeetVo.setActual(list7);
                entMeetVo.setLate(list8);
                entMeetVo.setLeave(list9);

                //旷会
                list7.addAll(list9);
                list6.stream().findFirst().map(vo -> {
                    list7.stream().forEach(item -> {
                        if (vo.equals(item)) {
                            list6.remove(vo);
                        }
                    });
                    return vo;
                });
                entMeetVo.setVast(list6);

                LambdaQueryWrapper<EntMeetSummary> meetSignLambdaQueryWrapper = new LambdaQueryWrapper<>();
                meetSignLambdaQueryWrapper.eq(EntMeetSummary::getMeetId, entMeetVo.getId());
                queryWrapper.eq(EntMeet::getDelFlag, UserStatus.OK.getCode());
                List<EntMeetSummary> listSummary = entMeetSummaryService.list();
                listSummary.stream().forEach(item -> {
                    if (item.getOptions() == 1) {//会议纪要
                        entMeetVo.getSummaryList().add(item);
                    } else {//会议决议
                        entMeetVo.getResolutionList().add(item);
                    }
                });
                listEntMeetVo.add(entMeetVo);
            }
        }
        return listEntMeetVo;
    }

    @Override
    public int signIn(Long id) {
        return entMeetSignService.insertInfo(id, MeetSignStatus.ONE.getCode());
    }

    @Override
    public int cancelMeet(Long id) {
        return entMeetSignService.insertInfo(id, MeetSignStatus.TWO.getCode());
    }

    @Override
    public int outside(List<EntInvite> inviteList) {
        int num = 0;
        for (EntInvite entInvite : inviteList) {
            num += entInviteService.insertEntInvite(entInvite);
        }
        return num;
    }

    @Override
    public int visa(Long id) {
        return entMeetSignService.insertInfo(id, MeetSignStatus.THREE.getCode());
    }

    @Override
    public int addMatter(MatterDto matterDto) {
        Integer num = 0;
        for (EntMeetRecord entMeetRecord : matterDto.getRecord()) {
            num += entMeetRecordService.insertInfo(entMeetRecord);
        }

        for (EntMeetSummary entMeetSummary : matterDto.getSummary()) {
            num += entMeetSummaryService.insertInfo(entMeetSummary);
        }

        return num;
    }

    @Override
    public int leave(Long id) {
        return entMeetSignService.insertInfo(id, MeetSignStatus.FOUR.getCode());
    }

    @Override
    public int start(Long id) {
        EntMeet entMeet = entMeetMapper.selectById(id);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        entMeet.setStatus(MeetStatus.TWO.getCode());
        return updateEntMeet(entMeet);
    }

    @Override
    public int conclude(Long id) {
        EntMeet entMeet = entMeetMapper.selectById(id);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        entMeet.setStatus(MeetStatus.THREE.getCode());
        return updateEntMeet(entMeet);
    }

    @Override
    public MatterVo listMatter(Long meetId) {
        MatterVo matterVo = new MatterVo();
        //纪要、决议
        LambdaQueryWrapper<EntMeetSummary> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(EntMeetSummary::getMeetId, meetId);
        lambdaQueryWrapper.eq(EntMeetSummary::getDelFlag, UserStatus.OK.getCode());
        List<EntMeetSummary> meetSummaryList = entMeetSummaryService.list(lambdaQueryWrapper);
        List<EntMeetSummary> listSummary = new ArrayList<>();
        List<EntMeetSummary> listResolution = new ArrayList<>();
        for (EntMeetSummary entMeetSummary : meetSummaryList) {
            entMeetSummary.setEndorse(String.valueOf(entMeetSummary.getEndorse().split(",").length));
            entMeetSummary.setAgainst(String.valueOf(entMeetSummary.getAgainst().split(",").length));
            entMeetSummary.setVote(String.valueOf(entMeetSummary.getVote().split(",").length));
            if (entMeetSummary.getOptions().equals(1)) {//1：纪要、2：决议
                listSummary.add(entMeetSummary);
            } else {
                listResolution.add(entMeetSummary);
            }
        }

        //会议记录
        LambdaQueryWrapper<EntMeetRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(EntMeetRecord::getMeetId, meetId);
        queryWrapper.eq(EntMeetRecord::getDelFlag, UserStatus.OK.getCode());
        List<EntMeetRecord> meetRecordList = entMeetRecordService.list(queryWrapper);

        matterVo.setRecord(meetRecordList);
        matterVo.setSummary(listSummary);
        matterVo.setResolution(listResolution);
        return matterVo;
    }

    @Override
    public EntMeet detail(Long id) {
        EntMeet entMeet = entMeetMapper.selectById(id);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        List<Long> conveners = Arrays.asList(StringsUtils.convert(entMeet.getConvener().split(",")));
        List<Long> principals = Arrays.asList(StringsUtils.convert(entMeet.getPrincipal().split(",")));
        List<Long> supervisions = Arrays.asList(StringsUtils.convert(entMeet.getSupervision().split(",")));
        List<Long> comperes = Arrays.asList(StringsUtils.convert(entMeet.getCompere().split(",")));
        List<Long> notekeepers = Arrays.asList(StringsUtils.convert(entMeet.getNotekeeper().split(",")));
        List<Long> arrayList = new ArrayList<>();
        arrayList.addAll(conveners);
        arrayList.addAll(principals);
        arrayList.addAll(supervisions);
        arrayList.addAll(comperes);
        arrayList.addAll(notekeepers);

        List<Long> interiorPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getInteriorPersonnel().split(",")));
        List<Long> externalPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getExternalPersonnel().split(",")));
        arrayList.addAll(interiorPersonnels);
        arrayList.addAll(externalPersonnels);

        arrayList.stream().distinct().collect(Collectors.toList());
        List<UserVo> listUser = remoteUserService.listInfo(arrayList.toArray(new Long[arrayList.size()])).getData();

        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();
        List<String> list3 = new ArrayList<>();
        List<String> list4 = new ArrayList<>();
        List<String> list5 = new ArrayList<>();
        List<String> list6 = new ArrayList<>();
        List<String> list7 = new ArrayList<>();
        for (UserVo userVo : listUser) {
            if (conveners.contains(userVo.getId())) {//会议召集人
                list1.add(userVo.getName());
            }
            if (principals.contains(userVo.getId())) {//会议负责人
                list2.add(userVo.getName());
            }
            if (supervisions.contains(userVo.getId())) {//会议督导人
                list3.add(userVo.getName());
            }
            if (comperes.contains(userVo.getId())) {//会议主持人
                list4.add(userVo.getName());
            }
            if (notekeepers.contains(userVo.getId())) {//会议记录人
                list5.add(userVo.getName());
            }
            //内部参会人员
            if (interiorPersonnels.contains(userVo.getId())) {
                list6.add(userVo.getName());
            }
            //外部参会人员
            if (externalPersonnels.contains(userVo.getId())) {
                list7.add(userVo.getName());
            }
        }

        entMeet.setConvener(String.join(" ", list1));
        entMeet.setPrincipal(String.join(" ", list2));
        entMeet.setSupervision(String.join(" ", list3));
        entMeet.setCompere(String.join(" ", list4));
        entMeet.setNotekeeper(String.join(" ", list5));
        entMeet.setInteriorPersonnel(String.join(" ", list6));
        entMeet.setExternalPersonnel(String.join(" ", list7));
        return entMeet;
    }

    @Override
    public JSONArray jurisdiction(Long meetId) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        EntMeet entMeet = entMeetMapper.selectById(meetId);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        List<Long> conveners = Arrays.asList(StringsUtils.convert(entMeet.getConvener().split(",")));
        List<Long> principals = Arrays.asList(StringsUtils.convert(entMeet.getPrincipal().split(",")));
        List<Long> supervisions = Arrays.asList(StringsUtils.convert(entMeet.getSupervision().split(",")));
        List<Long> comperes = Arrays.asList(StringsUtils.convert(entMeet.getCompere().split(",")));
        List<Long> notekeepers = Arrays.asList(StringsUtils.convert(entMeet.getNotekeeper().split(",")));
        JSONArray jsonArray = new JSONArray();
        if (conveners.contains(loginUser.getId())) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", "convener");
            jsonObject.put("name", "会议召集人");
            jsonArray.add(jsonObject);
        }
        if (principals.contains(loginUser.getId())) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", "principal");
            jsonObject.put("name", "会议负责人");
            jsonArray.add(jsonObject);
        }
        if (supervisions.contains(loginUser.getId())) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", "supervision");
            jsonObject.put("name", "会议督导人");
            jsonArray.add(jsonObject);
        }
        if (comperes.contains(loginUser.getId())) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", "compere");
            jsonObject.put("name", "会议主持人");
            jsonArray.add(jsonObject);
        }
        if (notekeepers.contains(loginUser.getId())) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("code", "notekeeper");
            jsonObject.put("name", "会议记录人");
            jsonArray.add(jsonObject);
        }
        return jsonArray;
    }

    @Override
    public int addSummaryVote(SummaryVoteDto summaryVoteDto) {
        EntMeet entMeet = entMeetMapper.selectById(summaryVoteDto.getId());
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        BeanUtils.copyProperties(summaryVoteDto, entMeet);
        return updateEntMeet(entMeet);
    }

    @Override
    public int addSummaryAppear(Long meetId, String summaryApprove) {
        EntMeet entMeet = entMeetMapper.selectById(meetId);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        entMeet.setSummaryApprove(summaryApprove);
        return updateEntMeet(entMeet);
    }

    @Override
    public int addMeetInterior(Long meetId, String interiorPersonnel) {
        EntMeet entMeet = entMeetMapper.selectById(meetId);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        if (StringUtils.isNotBlank(entMeet.getInteriorPersonnel())) {
            entMeet.setInteriorPersonnel(entMeet.getInteriorPersonnel() + "," + interiorPersonnel);
        } else {
            entMeet.setInteriorPersonnel(interiorPersonnel);
        }
        return updateEntMeet(entMeet);
    }

    @Override
    public int addMeetExternal(Long meetId, String externalPersonnel) {
        EntMeet entMeet = entMeetMapper.selectById(meetId);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        if (StringUtils.isNotBlank(entMeet.getExternalPersonnel())) {
            entMeet.setExternalPersonnel(entMeet.getExternalPersonnel() + "," + externalPersonnel);
        } else {
            entMeet.setExternalPersonnel(externalPersonnel);
        }
        return updateEntMeet(entMeet);
    }

    @Override
    public List<MeetPresentVo> listMeetPresent(Long meetId, Integer type) {
        EntMeet entMeet = entMeetMapper.selectById(meetId);
        if (entMeet == null) {
            throw new RuntimeException("记录没有找到！");
        }
        List<Long> arrayList = new ArrayList<>();
        List<Long> interiorPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getInteriorPersonnel().split(",")));
        List<Long> externalPersonnels = Arrays.asList(StringsUtils.convert(entMeet.getExternalPersonnel().split(",")));
        arrayList.addAll(interiorPersonnels);
        arrayList.addAll(externalPersonnels);

        arrayList.stream().distinct().collect(Collectors.toList());
        List<UserVo> listUser = remoteUserService.listInfo(arrayList.toArray(new Long[arrayList.size()])).getData();
        List<MeetPresentVo> list = new ArrayList<>();
        //应出席人
        if (type == 1) {
            for (UserVo userVo : listUser) {
                MeetPresentVo presentVo = new MeetPresentVo();
                presentVo.setMeetId(meetId);
                presentVo.setPortrait(userVo.getHeadImg());
                presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                presentVo.setPhone(userVo.getTelephone().toString());

                //签到和签离
                LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
                lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
                lambdaQueryWrapper.in(EntMeetSign::getStatus, 1, 3);
                lambdaQueryWrapper.eq(EntMeetSign::getCreateId, userVo.getId());
                List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
                for (EntMeetSign meetSign : meetSignList) {
                    if (meetSign.getStatus() == 1) {
                        presentVo.setSignTime(meetSign.getCreateTime());
                    }
                    if (meetSign.getStatus() == 3) {
                        presentVo.setVisaTime(meetSign.getCreateTime());
                    }
                }
                list.add(presentVo);
            }
        }

        //实际出席
        if (type == 2) {
            //签到
            LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
            lambdaQueryWrapper.in(EntMeetSign::getStatus, 1);
            List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
            for (EntMeetSign meetSign : meetSignList) {
                for (UserVo userVo : listUser) {
                    if (meetSign.getCreateId() == userVo.getId()) {
                        MeetPresentVo presentVo = new MeetPresentVo();
                        presentVo.setMeetId(meetId);
                        presentVo.setPortrait(userVo.getHeadImg());
                        presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                        presentVo.setPhone(userVo.getTelephone().toString());
                        presentVo.setSignTime(meetSign.getCreateTime());

                        lambdaQueryWrapper = new LambdaQueryWrapper<>();
                        lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
                        lambdaQueryWrapper.in(EntMeetSign::getStatus, 3);
                        lambdaQueryWrapper.eq(EntMeetSign::getCreateId, userVo.getId());
                        EntMeetSign meetSign1 = entMeetSignService.getOne(lambdaQueryWrapper);
                        if (meetSign1 != null) {
                            presentVo.setVisaTime(meetSign1.getCreateTime());
                        }
                        list.add(presentVo);
                    }
                }
            }
        }

        //未到/缺席
        if (type == 3) {
            //签到
            LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
            lambdaQueryWrapper.in(EntMeetSign::getStatus, 1);
            List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
            arrayList.stream().findFirst().map(vo -> {
                meetSignList.stream().forEach(item -> {
                    if (vo == item.getCreateId()) {
                        arrayList.remove(vo);
                    }
                });
                return vo;
            });

            for (UserVo userVo : listUser) {
                if (arrayList.contains(userVo.getId())) {
                    MeetPresentVo presentVo = new MeetPresentVo();
                    presentVo.setMeetId(meetId);
                    presentVo.setPortrait(userVo.getHeadImg());
                    presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                    presentVo.setPhone(userVo.getTelephone().toString());
//                    presentVo.setSignTime();
//                        presentVo.setVisaTime();
                    list.add(presentVo);
                }
            }
        }

        //迟到
        if (type == 4) {
            //签到
            LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
            lambdaQueryWrapper.in(EntMeetSign::getStatus, 1);
            lambdaQueryWrapper.le(EntMeetSign::getCreateTime, entMeet.getStartTime());
            List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
            for (EntMeetSign meetSign : meetSignList) {
                for (UserVo userVo : listUser) {
                    if (meetSign.getCreateId() == userVo.getId()) {
                        MeetPresentVo presentVo = new MeetPresentVo();
                        presentVo.setMeetId(meetId);
                        presentVo.setPortrait(userVo.getHeadImg());
                        presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                        presentVo.setPhone(userVo.getTelephone().toString());
                        presentVo.setSignTime(meetSign.getCreateTime());
//                        presentVo.setVisaTime();
                        list.add(presentVo);
                    }
                }
            }
        }
        //早退
        if (type == 5) {
            LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
            lambdaQueryWrapper.in(EntMeetSign::getStatus, 3);
            lambdaQueryWrapper.gt(EntMeetSign::getCreateTime, entMeet.getEntTime());
            List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
            for (EntMeetSign meetSign : meetSignList) {
                for (UserVo userVo : listUser) {
                    if (meetSign.getCreateId() == userVo.getId()) {
                        MeetPresentVo presentVo = new MeetPresentVo();
                        presentVo.setMeetId(meetId);
                        presentVo.setPortrait(userVo.getHeadImg());
                        presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                        presentVo.setPhone(userVo.getTelephone().toString());
//                        presentVo.setSignTime();
                        presentVo.setVisaTime(meetSign.getCreateTime());
                        list.add(presentVo);
                    }
                }
            }
        }
        //会议请假
        if (type == 6) {
            LambdaQueryWrapper<EntMeetSign> lambdaQueryWrapper = new LambdaQueryWrapper<>();
            lambdaQueryWrapper.eq(EntMeetSign::getMeetId, meetId);
            lambdaQueryWrapper.in(EntMeetSign::getStatus, 4);
            List<EntMeetSign> meetSignList = entMeetSignService.list(lambdaQueryWrapper);
            for (EntMeetSign meetSign : meetSignList) {
                for (UserVo userVo : listUser) {
                    if (meetSign.getCreateId() == userVo.getId()) {
                        MeetPresentVo presentVo = new MeetPresentVo();
                        presentVo.setMeetId(meetId);
                        presentVo.setPortrait(userVo.getHeadImg());
                        presentVo.setName(userVo.getName());
//                presentVo.setPortrait();
//                presentVo.setBranch();
                        presentVo.setPhone(userVo.getTelephone().toString());
//                        presentVo.setSignTime();
//                        presentVo.setVisaTime();
                        presentVo.setVacateTime(meetSign.getCreateTime());
                        list.add(presentVo);
                    }
                }
            }
        }
        return list;
    }
}
